home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / audio / midi / thru.c++ < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.5 KB  |  68 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include <midi.h>
  18. #include <midiio.h>
  19. #include <malloc.h>
  20. #include <stdio.h>
  21. #include <unistd.h>
  22. #include <string.h>
  23.  
  24. // Turn your Indigo into the worlds most expensive MIDI thru box!
  25.  
  26. #define BUFSZ 1
  27.  
  28. main(int argc, char **argv)
  29. {
  30.     MIport port;  
  31.     MIevent e[BUFSZ];
  32.     MIconfig c;
  33.     u_int pbuf[2];
  34.     int relative = 0;
  35.     int i = 0;
  36.  
  37.     if (argc > 1 && strcmp(argv[1],"-r") == 0) {
  38.     relative = 1;
  39.     pbuf[0] = MI_STAMPING;
  40.     pbuf[1] = MIRELSTAMP;
  41.     c.setparams(pbuf,2);
  42.     }
  43.     
  44.     
  45.     if (port.open("rt", &c) < 0) {
  46.     exit(-1);
  47.     }
  48.  
  49.     if (relative)
  50.     port.setstart((struct timeval *) 0);
  51.     
  52.     while (1) {
  53.     int retval;
  54.     
  55.     if ((retval = port.receive(e, BUFSZ)) < 0)  // receive 1 event 
  56.     {
  57.         exit(-1);
  58.     }
  59.  
  60.     if (retval > 0)
  61.         retval = port.send(e, retval);
  62.     
  63.     if (retval < 0) {
  64.         exit(-1);
  65.     }
  66.     }
  67. }
  68.